import java.util.Iterator;
import java.util.LinkedList;


public class OverlapsSolverRemoveWeakerCluster implements OverlapsSolver {
	/**
	 * Resolved overlaps by removing clusters that have overlaps and are considered lesser.
	 * The clusters least is assumed to be ordered s.t. the 'strongest' cluster is at the head 
	 * and the weaker is at the tail.
	 */
	public void solve(LinkedList<Cluster> clusters) {
		Iterator<Cluster> iter = clusters.descendingIterator();
		while (iter.hasNext()) {
			Cluster cluster = iter.next();
			for (Gene g: cluster) {
				if (g.clustersCount() > 1) {
					cluster.clear();
					iter.remove();
					break;
				}
			}
		}
	}

}
